package humanMirror.model.human;

/**
 * Basic class of human organ. It has only common for all organs characteristics
 * and methods.
 * 
 * @author Vasyl Khyzhniak, modified by Aleksandra
 * @version 1.1
 */
public class Parameter implements Cloneable {

    private final String name;
    private int parameter;
    private final int healthLower;
    private final int healthUpper;

    public Parameter(String name, int value) {
        healthLower = 0;
        healthUpper = 100;
        this.name = name;
        initializeHealth(value);
    }

    public String getName() {
        return name;
    }

    public int getValue() {
        return parameter;
    }

    public void setParametr(int parameter) {
        initializeHealth(parameter);
    }
    
    private void initializeHealth(int parameter) {
        if ((parameter < healthLower) || (parameter > healthUpper)) {
            throw new IllegalArgumentException("");
        }
        this.parameter = parameter;
    }
 
    
    @Override
    public boolean equals(Object obj) {
        if(this == obj) {
            return true;
        }
        
        if(!(obj instanceof  Parameter)) {
            return false;
        }
        
        return name.equals(((Parameter) obj).name);
    }

    @Override
    public int hashCode() {
        return name.hashCode();
    }
}